﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace FlexPlatform.GeneralUse
{
    using System.ComponentModel;
    using System.Linq.Expressions;

    public class NotifyPropertyChangedBase<T> : INotifyPropertyChanged
    {
        public event PropertyChangedEventHandler PropertyChanged;
        
        
        protected void RaisePropertyChangeEvent(string propertyName)
        {
            if (this.PropertyChanged != null)
            {
                PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
            }
        }

        protected void RaisePropertyChangeEvent(Expression<Func<T, object>> property)
        {
            if (this.PropertyChanged != null)
            {
                string propertyName = ReflectionHelper.GetPropertyName(property);
                PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
            }
        }
    }
}
